package cn.com.shopec.erp.provideinterface.commo;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import cn.com.shopec.erp.product.service.ICommodityService;
import cn.com.shopec.erp.product.vo.ProductVo1;
import cn.com.shopec.erp.provideinterface.entity.InventoryChange;
import cn.com.shopec.erp.provideinterface.vo.InventoryChangeVo;

@Component
public class InventoryChangeConvertor {
	
	@Resource 
	private ICommodityService commodityService;
	
	public InventoryChangeVo getInventoryChangeVo(InventoryChange ic) throws Exception{
		InventoryChangeVo icVo = new InventoryChangeVo();
		icVo.setId(ic.getId());
		icVo.setWarehouseCode(ic.getWarehouseCode());
		icVo.setOrderNo(ic.getOrderNo());
		icVo.setModuleCode(ic.getModuleCode());
		icVo.setSku(ic.getSku());
		icVo.setQty(Integer.valueOf(ic.getQty()));
		icVo.setAuditor(ic.getAuditor());
		icVo.setAuditTime(ic.getAuditTime());
		icVo.setRemark(ic.getRemark());
		icVo.setIsGrab(ic.getIsGrab());
		icVo.setPINo(ic.getPINo());
		ProductVo1 product = commodityService.getProduct(ic.getSku());
		icVo.setProduct(product);
		return icVo;
	}
	
	public List<InventoryChangeVo> getListVo(List<InventoryChange> list) throws Exception{
		List<InventoryChangeVo> listVo = new ArrayList<InventoryChangeVo>();
		for (InventoryChange icVo : list) {
			listVo.add(getInventoryChangeVo(icVo));
		}
		return listVo;
	}
}
